#ifndef _BANKMGR_H_
#define _BANKMGR_H_

class CBankMgr
{
private:
	static const u32 UNIT_COUNT = 16;
	static const u32 CELL_COUNT = UNIT_COUNT * 32;
	
	
	u32 m_cellSize;
	u32 m_units[UNIT_COUNT];
	u32 m_baseAddr;
	u32 m_free;
	u32 m_lastAlloc;
protected:
	BOOL isFreeCell(u32 b);
	void setFreeCell(u32 b);
	void setFullCell(u32 b);
	BOOL findFreeSpace(u32 p1, u32 p2, u32 size, u32 *cell);

	u32 toCells(u32 size);
public:
	CBankMgr(u32 size, u32 baseAddr);
	
	BOOL alloc(u32 size, u32 *addr);
	s32 alloc(u32 size);
	void dealloc(u32 addr, u32 size);
	
};

#endif //_BANKMGR_H_